import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '../layout/Index'

Vue.use(VueRouter)


export const constantRoutes = [
    {
        path: '/',
        visible: false,
        redirect: '/login'
    },
    //    登录
    {
        path: '/login',
        name: 'login',
        visible: false,
        meta: {
            title: '登录',
            icon: 'mdi-fingerprint',
            keepAlive: false,
            requiresAuth: false
        },
        component: () => import('../views/login/Index')
    },
]

/**
 * 模拟从后台加载出来的菜单列表
 *  管理员权限
 * @type {[{path: string, component, visible: boolean, children: [{path: string, component: (function(): Promise<*>), meta: {requiresAuth: boolean, keepAlive: boolean, icon: string, title: string}, name: string}], meta: {requiresAuth: boolean, keepAlive: boolean, icon: string, title: string}},{redirect: string, path: string, component, visible: boolean, children: [{path: string, component: (function(): Promise<*>), meta: {requiresAuth: boolean, keepAlive: boolean, icon: string, title: string}, name: string},{path: string, component: (function(): Promise<*>), meta: {requiresAuth: boolean, keepAlive: boolean, icon: string, title: string}, name: string}], meta: {requiresAuth: boolean, keepAlive: boolean, icon: string, title: string}}]}
 */
export const DynamicRoutes = [
    //  首页
    {
        path: '/home',
        visible: true,
        component: layout,
        meta: {
            title: '首页',
            icon: 'mdi-gauge',
            keepAlive: false,
            requiresAuth: true
        },
        children: [
            {
                path: '',
                name: 'home',
                meta: {
                    title: '首页',
                    icon: 'mdi-gauge',
                    keepAlive: false,
                    requiresAuth: true
                },
                component: () => import('../views/home/Index')
            },
        ]
    },
//    测试 food-turkey
    {
        path: '/test',
        visible: false,
        redirect: '/test/index',
        component: layout,
        meta: {
            title: '测试',
            icon: 'mdi-view-comfy',
            keepAlive: false,
            requiresAuth: true
        },
        children: [
            {
                path: 'index',
                name: 'testIndex',
                meta: {
                    title: '测试首页',
                    icon: 'mdi-alpha-w',
                    keepAlive: false,
                    requiresAuth: true
                },
                component: () => import('../views/test/Index')
            },
            {
                path: 'hello',
                name: 'testHello',
                meta: {
                    title: 'hello',
                    icon: 'mdi-alpha-w',
                    keepAlive: false,
                    requiresAuth: true
                },
                component: () => import('../views/test/hello')
            },
        ]
    },
  {
    path: '/business',
    visible: true,
    redirect: '/business/index',
    component: layout,
    meta: {
      title: '商家/商品',
      icon: 'mdi-food-turkey',
      keepAlive: false,
      requiresAuth: true
    },
    children: [
      {
        path: 'index',
        name: 'Business',
        meta: {
          title: '商家管理',
          icon: 'mdi-alpha-w',
          keepAlive: false,
          requiresAuth: true
        },
        component: () => import('../views/business/Index')
      },
        {
            path: 'businessPage',
            name: 'BusinessPage',
            hide: true,
            meta: {
                title: '商家详情',
                icon: 'mdi-alpha-w',
                keepAlive: false,
                requiresAuth: true
            },
            component: () => import('../views/business/BusinessPage')
        },
      {
        path: 'goods',
        name: 'Goods',
        meta: {
          title: '商品管理',
          icon: 'mdi-alpha-w',
          keepAlive: false,
          requiresAuth: true
        },
        component: () => import('../views/goods/Index')
      },
    ]
  },
    {
        path: '/order',
        visible: true,
        redirect:'/order/index',
        component: layout,
        meta: {
            title: '订单管理',
            icon: 'mdi-order-alphabetical-ascending',
            keepAlive: false,
            requiresAuth: true
        },
        children: [
            {
                path: 'index',
                name: 'OrderIndex',
                meta: {
                    title: '订单管理',
                    icon: 'mdi-alpha-w',
                    keepAlive: false,
                    requiresAuth: true
                },
                component: () => import('../views/order/Index')
            },
            {
                path: 'orderDetails',
                name: 'OrderDetails',
                hide:true,
                meta: {
                    title: '订单详情',
                    icon: 'mdi-alpha-w',
                    keepAlive: false,
                    requiresAuth: true
                },
                component: () => import('../views/order/OrderDetails')
            }
        ]
    },
]

/**
 * 模拟商家路由
 * @type {[{path: string, component, visible: boolean, children: [{path: string, component: (function(): Promise<*>), meta: {requiresAuth: boolean, keepAlive: boolean, icon: string, title: string}, name: string}], meta: {requiresAuth: boolean, keepAlive: boolean, icon: string, title: string}},{redirect: string, path: string, component, visible: boolean, children: [{path: string, component: (function(): Promise<*>), meta: {requiresAuth: boolean, keepAlive: boolean, icon: string, title: string}, name: string},{path: string, component: (function(): Promise<*>), meta: {requiresAuth: boolean, keepAlive: boolean, icon: string, title: string}, name: string}], meta: {requiresAuth: boolean, keepAlive: boolean, icon: string, title: string}}]}
 */
export const BusinessDynamicRoutes = [
    //  首页
    {
        path: '/home',
        visible: true,
        component: layout,
        meta: {
            title: '首页',
            icon: 'mdi-gauge',
            keepAlive: false,
            requiresAuth: true
        },
        children: [
            {
                path: '',
                name: 'home',
                meta: {
                    title: '首页',
                    icon: 'mdi-gauge',
                    keepAlive: false,
                    requiresAuth: true
                },
                component: () => import('../views/home/Index')
            },
        ]
    },
    {
        path: '/business',
        visible: true,
        redirect: '/business/index',
        component: layout,
        meta: {
            title: '商家/商品',
            icon: 'mdi-food-turkey',
            keepAlive: false,
            requiresAuth: true
        },
        children: [
            {
                path: 'index',
                name: 'BusinessDetails',
                meta: {
                    title: '商家详情',
                    icon: 'mdi-alpha-w',
                    keepAlive: false,
                    requiresAuth: true
                },
                component: () => import('../views/business/BusinessDetails')
            },
            {
                path: 'goodsCategory',
                name: 'GoodsCategory',
                meta: {
                    title: '商品分类',
                    icon: 'mdi-alpha-w',
                    keepAlive: false,
                    requiresAuth: true
                },
                component: () => import('../views/goods/GoodsCategory')
            },
            {
                path: 'goods',
                name: 'Goods',
                meta: {
                    title: '商品管理',
                    icon: 'mdi-alpha-w',
                    keepAlive: false,
                    requiresAuth: true
                },
                component: () => import('../views/goods/Index')
            },
            {
                path: 'editGoods',
                name: 'EditGoods',
                hide:true,
                meta: {
                    title: '商品编辑',
                    icon: 'mdi-alpha-w',
                    keepAlive: false,
                    requiresAuth: true
                },
                component: () => import('../views/goods/EditGoods')
            },
        ]
    },
    {
        path: '/order',
        visible: true,
        redirect:'/order/index',
        component: layout,
        meta: {
            title: '订单管理',
            icon: 'mdi-order-alphabetical-ascending',
            keepAlive: false,
            requiresAuth: true
        },
        children: [
            {
                path: 'index',
                name: 'OrderIndex',
                meta: {
                    title: '订单管理',
                    icon: 'mdi-alpha-w',
                    keepAlive: false,
                    requiresAuth: true
                },
                component: () => import('../views/order/Index')
            },
            {
                path: 'orderDetails',
                name: 'OrderDetails',
                hide:true,
                meta: {
                    title: '订单详情',
                    icon: 'mdi-alpha-w',
                    keepAlive: false,
                    requiresAuth: true
                },
                component: () => import('../views/order/OrderDetails')
            }
        ]
    },
]


const router = new VueRouter({
    base:'qydc',
    mode: 'history',
    routes: constantRoutes
})

export default router
